﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Windows.Forms;

    public class clsHopDongMuaBanChiTiet
    {
        private double mDonGia = 0.0;
        private string mKhoa = "";
        private string mKhoaDonViTinh = "";
        private string mKhoaHangHoa = "";
        private string mKhoaHangSanXuat = "";
        private string mKhoaHopDongMuaBan = "";
        private string mKhoaQuocGia = "";
        private string mKhoaThietBi = "";
        private string mLoai = "";
        private double mQuyCach = 0.0;
        private double mSoLuong = 0.0;
        private int mThoiGianBaoHanh = 0;
        private double mTienChietKhau = 0.0;
        private double mTienHang = 0.0;
        private double mTienThue = 0.0;
        private int mTyLeChietKhau = 0;
        private int mTyLeThue = 0;

        public bool Load(string pKhoa)
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[2];
            try
            {
                string commandText = "SELECT * FROM BH_HopDongMuaBanChiTiet WHERE Khoa = '" + pKhoa + "'";
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, commandParameters);
                if (dataReader.Read())
                {
                    this.mKhoa = Conversions.ToString(modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString));
                    this.mKhoaHopDongMuaBan = Conversions.ToString(modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString));
                    this.mKhoaHangHoa = Conversions.ToString(modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetString));
                    this.mKhoaQuocGia = Conversions.ToString(modGeneral.GetValue(dataReader, 3, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDonViTinh = Conversions.ToString(modGeneral.GetValue(dataReader, 4, modGeneral.typeOfColumn.GetString));
                    this.mQuyCach = Conversions.ToDouble(modGeneral.GetValue(dataReader, 5, modGeneral.typeOfColumn.GetDecimal));
                    this.mSoLuong = Conversions.ToDouble(modGeneral.GetValue(dataReader, 6, modGeneral.typeOfColumn.GetDecimal));
                    this.mDonGia = Conversions.ToDouble(modGeneral.GetValue(dataReader, 7, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienHang = Conversions.ToDouble(modGeneral.GetValue(dataReader, 8, modGeneral.typeOfColumn.GetDecimal));
                    this.mTyLeChietKhau = Conversions.ToInteger(modGeneral.GetValue(dataReader, 9, modGeneral.typeOfColumn.GetInt32));
                    this.mTienChietKhau = Conversions.ToDouble(modGeneral.GetValue(dataReader, 10, modGeneral.typeOfColumn.GetDecimal));
                    this.mTyLeThue = Conversions.ToInteger(modGeneral.GetValue(dataReader, 11, modGeneral.typeOfColumn.GetInt32));
                    this.mTienThue = Conversions.ToDouble(modGeneral.GetValue(dataReader, 12, modGeneral.typeOfColumn.GetDecimal));
                    this.mKhoaThietBi = Conversions.ToString(modGeneral.GetValue(dataReader, 13, modGeneral.typeOfColumn.GetString));
                    this.mLoai = Conversions.ToString(modGeneral.GetValue(dataReader, 14, modGeneral.typeOfColumn.GetString));
                    this.mKhoaHangSanXuat = Conversions.ToString(modGeneral.GetValue(dataReader, 15, modGeneral.typeOfColumn.GetString));
                    this.mThoiGianBaoHanh = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x10, modGeneral.typeOfColumn.GetInt32));
                }
                dataReader.Close();
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool Save()
        {
            bool flag2;
            IDataParameter[] commandParameters = new IDataParameter[0x11];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@KhoaHopDongMuaBan", DbType.Int64, ParameterDirection.Input, this.mKhoaHopDongMuaBan);
                commandParameters[2] = DBHelper.createParameter("@KhoaHangHoa", DbType.Int64, ParameterDirection.Input, this.mKhoaHangHoa);
                commandParameters[3] = DBHelper.createParameter("@KhoaQuocGia", DbType.Int64, ParameterDirection.Input, this.mKhoaQuocGia);
                commandParameters[4] = DBHelper.createParameter("@KhoaDonViTinh", DbType.Int64, ParameterDirection.Input, this.mKhoaDonViTinh);
                commandParameters[5] = DBHelper.createParameter("@QuyCach", DbType.Date, ParameterDirection.Input, this.mQuyCach);
                commandParameters[6] = DBHelper.createParameter("@SoLuong", DbType.Date, ParameterDirection.Input, this.mSoLuong);
                commandParameters[7] = DBHelper.createParameter("@DonGia", DbType.Date, ParameterDirection.Input, this.mDonGia);
                commandParameters[8] = DBHelper.createParameter("@TienHang", DbType.Date, ParameterDirection.Input, this.mTienHang);
                commandParameters[9] = DBHelper.createParameter("@TyLeChietKhau", DbType.Double, ParameterDirection.Input, this.mTyLeChietKhau);
                commandParameters[10] = DBHelper.createParameter("@TienChietKhau", DbType.Date, ParameterDirection.Input, this.mTienChietKhau);
                commandParameters[11] = DBHelper.createParameter("@TyLeThue", DbType.Double, ParameterDirection.Input, this.mTyLeThue);
                commandParameters[12] = DBHelper.createParameter("@TienThue", DbType.Date, ParameterDirection.Input, this.mTienThue);
                commandParameters[13] = DBHelper.createParameter("@KhoaThietBi", DbType.Int64, ParameterDirection.Input, this.mKhoaThietBi);
                commandParameters[14] = DBHelper.createParameter("@Loai", DbType.Int64, ParameterDirection.Input, this.mLoai);
                commandParameters[15] = DBHelper.createParameter("@KhoaHangSanXuat", DbType.Int64, ParameterDirection.Input, this.mKhoaHangSanXuat);
                commandParameters[0x10] = DBHelper.createParameter("@ThoiGianBaoHanh", DbType.Double, ParameterDirection.Input, this.mThoiGianBaoHanh);
                bool flag = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "BH_sp_HopDongMuaBanChiTiet", commandParameters) > 0;
                flag2 = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag2 = false;
                ProjectData.ClearProjectError();
                return flag2;
                ProjectData.ClearProjectError();
            }
            return flag2;
        }

        public double DonGia
        {
            get
            {
                return this.mDonGia;
            }
            set
            {
                this.mDonGia = value;
            }
        }

        public string Khoa
        {
            get
            {
                return this.mKhoa;
            }
            set
            {
                this.mKhoa = value;
            }
        }

        public string KhoaDonViTinh
        {
            get
            {
                return this.mKhoaDonViTinh;
            }
            set
            {
                this.mKhoaDonViTinh = value;
            }
        }

        public string KhoaHangHoa
        {
            get
            {
                return this.mKhoaHangHoa;
            }
            set
            {
                this.mKhoaHangHoa = value;
            }
        }

        public string KhoaHangSanXuat
        {
            get
            {
                return this.mKhoaHangSanXuat;
            }
            set
            {
                this.mKhoaHangSanXuat = value;
            }
        }

        public string KhoaHopDongMuaBan
        {
            get
            {
                return this.mKhoaHopDongMuaBan;
            }
            set
            {
                this.mKhoaHopDongMuaBan = value;
            }
        }

        public string KhoaQuocGia
        {
            get
            {
                return this.mKhoaQuocGia;
            }
            set
            {
                this.mKhoaQuocGia = value;
            }
        }

        public string KhoaThietBi
        {
            get
            {
                return this.mKhoaThietBi;
            }
            set
            {
                this.mKhoaThietBi = value;
            }
        }

        public string Loai
        {
            get
            {
                return this.mLoai;
            }
            set
            {
                this.mLoai = value;
            }
        }

        public double QuyCach
        {
            get
            {
                return this.mQuyCach;
            }
            set
            {
                this.mQuyCach = value;
            }
        }

        public double SoLuong
        {
            get
            {
                return this.mSoLuong;
            }
            set
            {
                this.mSoLuong = value;
            }
        }

        public int ThoiGianBaoHanh
        {
            get
            {
                return this.mThoiGianBaoHanh;
            }
            set
            {
                this.mThoiGianBaoHanh = value;
            }
        }

        public double TienChietKhau
        {
            get
            {
                return this.mTienChietKhau;
            }
            set
            {
                this.mTienChietKhau = value;
            }
        }

        public double TienHang
        {
            get
            {
                return this.mTienHang;
            }
            set
            {
                this.mTienHang = value;
            }
        }

        public double TienThue
        {
            get
            {
                return this.mTienThue;
            }
            set
            {
                this.mTienThue = value;
            }
        }

        public int TyLeChietKhau
        {
            get
            {
                return this.mTyLeChietKhau;
            }
            set
            {
                this.mTyLeChietKhau = value;
            }
        }

        public int TyLeThue
        {
            get
            {
                return this.mTyLeThue;
            }
            set
            {
                this.mTyLeThue = value;
            }
        }
    }
}

